package de.rj.urwalking.util;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import de.rj.urwalking.R;
import de.rj.urwalking.data.Perspective;

public class PerspectiveAdapter extends ArrayAdapter<Integer> {

	private Context context;

	public PerspectiveAdapter(Context context, List<Integer> objects) {
		super(context, R.layout.sherlock_spinner_item, android.R.id.text1, objects);
		this.context = context;

	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.sherlock_spinner_item, parent, false);

		TextView textView = (TextView) rowView.findViewById(android.R.id.text1);

		Integer item = getItem(position);
		textView.setText(Perspective.getName(item));

		return rowView;

	}

	@Override
	public View getDropDownView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.sherlock_spinner_dropdown_item, parent, false);

		TextView textView = (TextView) rowView.findViewById(android.R.id.text1);

		Integer item = getItem(position);
		textView.setText(Perspective.getName(item));

		return rowView;

	}

}
